class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
  before_action :set_devise_permit, if: :devise_controller?


  protected

  def after_sign_out_path_for(resource_or_scope)
    request.referrer
  end

  # 自定义Devise可用栏目
  def set_devise_permit
    registration_params = [:intro, :name, :email, :password, :password_confirmation]
    if params[:action] == 'update'
      devise_parameter_sanitizer.for(:account_update) {
          |u| u.permit(registration_params << :current_password)
      }
    elsif params[:action] == 'create'
      devise_parameter_sanitizer.for(:sign_up) {
          |u| u.permit(registration_params)
      }
    end
  end

  def get_page
    if params[:page]
      params[:page]
    else
      1
    end
  end

end
